package com.sc.test.dagger2;

import android.os.Bundle;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.sc.test.R;
import com.sc.test.app.App;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Shen Chao.
 * Created on 2018-06-03-003.
 */

public class SecondActivity extends AppCompatActivity {
    @Inject
    Cloth blueCloth;
    @Inject
    ClothHandler clothHandler;
    @BindView(R.id.tv_dagger_second)
    TextView tvDaggerSecond;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dagger2_second);
        ButterKnife.bind(this);
//        DaggerSecondComponent.create().inject(this);
//        DaggerSecondComponent.builder().secondModule(new SecondModule()).build();
        SecondComponent build = DaggerSecondComponent
                .builder()
                .baseComponent(((App) getApplication()).getBaseComponent())
                .secondModule(new SecondModule())
                .build();
        build.inject(this);
        tvDaggerSecond.setText("蓝颜料：" + clothHandler.handle(blueCloth) + ":" + clothHandler);

    }
}
